package com.cskaoyan.bean.promotion.topic;

import com.cskaoyan.util.DateUtils;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;
import java.util.Date;

@NoArgsConstructor
public class Topic {
    private Integer id;

    private String title;

    private String subtitle;

    private BigDecimal price;

    private String readCount;

    private String picUrl;

    private Integer sortOrder;

    private Integer[] goods;

    private Date addTime;

    private Date updateTime;

    private Boolean deleted;

    private String content;


    public Topic(UpdateTopicBO topicBO) {
        this.id = topicBO.getId();
        this.title = topicBO.getTitle();
        this.subtitle = topicBO.getSubtitle();
        this.price = BigDecimal.valueOf(topicBO.getPrice());
        this.readCount = topicBO.getReadCount();
        this.picUrl = topicBO.getPicUrl();
        this.sortOrder = topicBO.getSortOrder();
        this.goods = topicBO.getGoods();
        if (topicBO.getAddTime() != null) {
            this.addTime = DateUtils.parseDate(topicBO.getAddTime());
        }
        this.updateTime = new Date();
        this.deleted = topicBO.getDeleted();
        this.content = topicBO.getContent();

    }

    public Topic(CreateTopicBO topicBO) {

        this.title = topicBO.getTitle();
        this.subtitle = topicBO.getSubtitle();
        this.price = BigDecimal.valueOf(topicBO.getPrice());
        this.readCount = topicBO.getReadCount();
        this.picUrl = topicBO.getPicUrl();
        this.goods = topicBO.getGoods();
        this.addTime = new Date();
        this.updateTime = new Date();
        this.deleted = false;
        this.content = topicBO.getContent();


    }

    public Topic(Integer id, String title, String subtitle, BigDecimal price, String readCount,
                 String picUrl, Integer sortOrder,
                 Integer[] goods, Date addTime, Date updateTime, Boolean deleted, String content) {

        this.id = id;
        this.title = title;
        this.subtitle = subtitle;
        this.price = price;
        this.readCount = readCount;
        this.picUrl = picUrl;
        this.sortOrder = sortOrder;
        this.goods = goods;
        this.addTime = addTime;
        this.updateTime = updateTime;
        this.deleted = deleted;
        this.content = content;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title == null ? null : title.trim();
    }

    public String getSubtitle() {
        return subtitle;
    }

    public void setSubtitle(String subtitle) {
        this.subtitle = subtitle == null ? null : subtitle.trim();
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    public String getReadCount() {
        return readCount;
    }

    public void setReadCount(String readCount) {
        this.readCount = readCount == null ? null : readCount.trim();
    }

    public String getPicUrl() {
        return picUrl;
    }

    public void setPicUrl(String picUrl) {
        this.picUrl = picUrl == null ? null : picUrl.trim();
    }

    public Integer getSortOrder() {
        return sortOrder;
    }

    public void setSortOrder(Integer sortOrder) {
        this.sortOrder = sortOrder;
    }

    public Integer[] getGoods() {
        return goods;
    }

    public void setGoods(Integer[] goods) {
        this.goods = goods;
    }

    public Date getAddTime() {
        return addTime;
    }

    public void setAddTime(Date addTime) {
        this.addTime = addTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public Boolean getDeleted() {
        return deleted;
    }

    public void setDeleted(Boolean deleted) {
        this.deleted = deleted;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content == null ? null : content.trim();
    }
}